package com.chao.cloudconsumerpayment8002.controller;

import com.chao.cloudconsumerpayment8002.service.PaymentService;
import com.chao.entities.CommonResult;
import com.chao.entities.Payment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 * @date 2021-06-08 16:07
 */
@RestController
public class ConsumerPaymentController {

    @Value("${server.port}")
    private Integer serverPort;

    @Autowired
    private PaymentService paymentService;

    @PostMapping(value = "/consumer/payment/creat")
    public CommonResult creatPayment(@RequestBody Payment payment){
        return paymentService.creatPayment(payment);
    }

    @GetMapping(value = "/consumer/payment/get/{id}")
    public CommonResult getPayment(@PathVariable("id") Long id){
        /*if(id < 0) {
            throw new RuntimeException("id不能为负数");
        }*/
        return paymentService.getPayment(id);
    }

    @GetMapping(value = "/comsumer/payment/getPort")
    public Integer getPort(){
        return serverPort;
    }

}
